@use "../../assets/scss/mixins/size" as *;

@function num($input) {
  @return calc($input / 1);
}
//  default font scale bounding
$font-lock-min: 400px !default;
$font-lock-max: 1000px !default;

//  font-size
@mixin font-size(
  $min,
  // font-size
  $max: null,
  // optional maximum font size
  $lock-min: $font-lock-min,
  // optional minimum viewport width
  $lock-max: $font-lock-max // optional maximum viewport width
) {
  & {
    font-size: $min;
  }
  @if $max {
    @media (min-width: $lock-min) {
      & {
        font-size: calc(
          #{$min} + #{num($max) - num($min)} * (100vw - #{$lock-min}) / #{num(
              $lock-max
            ) - num($lock-min)}
        );
      }
    }
    @media (min-width: $lock-max) {
      & {
        font-size: $max;
      }
    }
  }
}

html {
  //   box-sizing: border-box;
  //根元素字体大小；10 / 16 = 62.5%，采用rem单位时，1rem = 10px
  // font-size: 62.5%;
  @include font-size(15px, 24px, 320px, 960px);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
  &:before,
  &:after {
    box-sizing: inherit;
  }
}
$bgColor: #bbb;
$lidColor: #222;

body {
  width: 100%;
  height: 100vh;
  background-color: $bgColor;
  font-family: "Raleway", Arial, Helvetica, sans-serif;
}

.five {
  width: 500px;
  position: relative;
  left: 50%;
  top: 80px;
  margin-left: -250px;
  user-select: none;
  .head {
    background-color: #777;
    background-image: linear-gradient(
      to right,
      #999 0%,
      #888 40%,
      #888 60%,
      #999 100%
    );
    width: 490px;
    height: 170px;
    position: relative;
    // margin: 0 auto;
    border-radius: 6px;
    z-index: 3;
    @include pseudo {
      background-color: #999;

      width: 17%;
      height: 50%;
      border-radius: inherit;
      bottom: -15%;
    }
    &::after {
      right: -2px;
      transform: rotateX(0) rotateY(0) rotateZ(4deg);
    }
    .antenna {
      position: absolute;
      left: 5%;
      top: -15px;
      background-color: #aaa;
      height: 8px;
      width: 20px;
      @include pseudo;
      &::before {
        background-color: #8a8a8a;
        height: 7px;
        width: 26px;
        left: -3px;
        top: 8px;
      }
      &::after {
        left: 3px;
        top: -15px;
        background-color: #7e685c;
        height: 15px;
        width: 14px;
      }
    }
    .controller {
      position: absolute;
      top: -30px;
      right: 20%;
      width: 0;
      height: 0;
      border-style: solid;
      border-width: 0 0 30px 15px;
      border-color: transparent transparent #666 transparent;
      @include pseudo_before {
        background-color: #555;
        top: 0;
        height: 8px;
        width: 40px;
        left: -20px;
        transform: rotateX(0) rotateY(0) rotateZ(4deg);
      }
    }
    .lid {
      background-color: $lidColor;
      position: absolute;
      width: 180px;
      height: 60px;
      top: -20px;
      left: -40px;
      box-shadow: 5px 10px 20px -8px black;
      transform: rotateX(70deg) rotateY(-4deg) rotateZ(0);
      border-radius: 30px 15px;
      transition: all 0.3s ease-in-out;
      &::after {
        content: "";
        position: absolute;
        width: 90px;
        height: 55px;
        top: 0;
        right: -60px;
        border-radius: 15px;
        background-color: $lidColor;
      }
      &.right {
        height: 50px;
        right: -40px;
        left: auto;
        transform: rotateX(70deg) rotateY(3deg) rotateZ(0);
        border-radius: 15px 30px;
        @include pseudo;
        &::after {
          left: -60px;
        }
        &::before {
          background-color: $lidColor;
          width: 60px;
          height: 55px;
          bottom: -10px;
          right: 0;
          border-radius: 10px;
        }
      }
    }
    .center-eyes {
      @include pos_tl(10px, 40%);
      @include rect(20%, 60%, #444, 4px);
      background-image: linear-gradient(
        to bottom,
        #999 0%,
        #777 35%,
        #777 50%,
        #777 65%,
        #999 100%
      );
      background-size: 100%;
      @include pseudo_before {
        @include rect(90%, 10px, $lidColor, 2px);
        top: 30px;
        left: 5px;
      }

      .join {
        @include pos_tl(10px, unset);
        @include rect(29px, 16px, #5a5a5a);
        &.left {
          left: 10px;
        }
        &.right {
          right: 10px;
        }
      }
    }
    .shadows {
      position: relative;
      top: 60px;
      left: 160px;
      width: 170px;
      height: 80px;
      @include pseudo {
        @include rect(125, 70, #888, 10px);
        z-index: -1;
        box-shadow: 0 0 4px #666;
        top: 10px;
      }
      &::before {
        left: -100px;
        transform: rotateX(0) rotateY(0) rotateZ(-20deg);
      }
      &::after {
        right: -100px;
        transform: rotateX(0) rotateY(0) rotateZ(20deg);
      }
    }
    .mouth-area {
      @include pos_tl(88%, 34.5%);
      @include rect(140, 20, #777, 0 0 6px 6px);
      padding: 14px 5px 10px;
      border-top: 2px solid #666;
      @include pseudo_before {
        z-index: -1;
        @include rect(165px, 16px, #777);
        top: -10px;
        left: -8px;
        box-shadow: inset 0 0 4px #555;
      }
      .mouth {
        @include rect(100%, 12px, #222);
        border-top: 2px solid #777;
        @include pseudo {
          @include rect(30px, 20px, #777);
          bottom: -6px;
        }
        &::before {
          left: 0;
          border-radius: 0 0 20px 4px;
        }
        &::after {
          right: 0;
          border-radius: 0 0 4px 20px;
        }
      }
    }
    .lower-lids {
      position: absolute;
      top: 100%;
      width: 100%;
      .lower-lid {
        background-color: $lidColor;
        display: block;
        position: absolute;
        padding: 20px;
        width: 110px;
        height: 60px;
        z-index: 10;
        top: -26px;
        border-radius: 30px 15px;
        box-shadow: 5px 10px 20px -8px black;
        transform: rotateX(-80deg) rotateY(-2deg) rotateZ(0);
        transition: all 0.3s ease-in-out;
        @include pseudo_after {
          bottom: 0;
          right: -26px;
          @include rect(50px, 60px, $lidColor, 12px);
        }
        &.left {
          left: -10px;
        }
        &.right {
          right: -10px;
          border-radius: 15px 30px;
          transform: rotateX(-80deg) rotateY(-2deg) rotateZ(0);
          &::after {
            left: -26px;
          }
        }
      }
      .lower-connect {
        position: absolute;
        z-index: 11;
        @include rect(14px, 18px, #333);
        border-bottom: 3px solid #444;
        &.left {
          left: 18%;
          transform: rotateX(0deg) rotateY(0deg) rotateZ(2deg);
        }
        &.right {
          right: 18%;
          transform: rotateX(0deg) rotateY(0deg) rotateZ(4deg);
        }
      }
    }
    .eye {
      position: absolute;
      @include circle(150, #000);
      bottom: 1%;
      z-index: 1;
      border: 2px solid #444;
      @include pseudo {
        width: 0;
        height: 0;
      }
      &.left {
        left: 1%;
        box-shadow: -3px -2px 2px #333;
        &::before,
        &::after {
          border-width: 35px 20px 0 0;
          border-color: #888 transparent transparent transparent;
        }
        &::before {
          top: 25px;
          left: -10%;
        }
        &::after {
          top: 15px;
          left: -13px;
        }
      }
      &.right {
        right: 1%;
        box-shadow: 3px -2px 2px #333;
        &::before,
        &::after {
          border-color: transparent #888 transparent transparent;
          border-width: 0 20px 35px 0;
        }
        &::before {
          top: 25px;
          right: -10%;
        }
        &::after {
          top: 15px;
          right: -13px;
        }
        .pupil:after {
          left: 15px;
        }
      }
      .outer,
      .inner,
      .zoom,
      .rim,
      .pupil {
        border-radius: 50%;
        background-color: #000;
        position: absolute;
      }
      .outer {
        top: 1px;
        left: 1px;
        width: 140px;
        height: 140px;
        border: 4px solid #7e685c;
      }
      .inner {
        top: 9px;
        left: 9px;
        width: 120px;
        height: 120px;
        border: 6px solid #584035;
      }
      .zoom {
        top: 16px;
        left: 16px;
        width: 110px;
        height: 110px;
        background-color: #89653c;
        border: 4px solid #cea26f;
      }
      .rim {
        top: 30px;
        left: 30px;
        width: 90px;
        height: 90px;
        background-color: #54554d;
        box-shadow: inset 0 0 2px 2px #333;
      }
      .pupil {
        top: 52px;
        left: 50px;
        width: 50px;
        height: 50px;
        transition: all 0.3s ease-in-out;
        &::after {
          content: "";
          position: absolute;
          background-color: #ccc;
          width: 10px;
          height: 10px;
          bottom: 2px;
          left: 20px;
          border-radius: 50%;
          transition: all 0.3s ease-in-out;
        }
      }
    }
  }
}
